/*学院设置*/ 
import React,{Component} from 'react';

import { Table} from 'antd';

import college from './index.module.css'

export default class SetCollege extends Component{
    state={
        columns:[
            {
              title: '编号',
              dataIndex: 'index',
              key: 'index',
            },
            {
              title: '学院名称',
              dataIndex: 'college',
              key: 'index',
            },
            {
              title: '总人数',
              dataIndex: 'num',
              key: 'index',
            },
          ],
          data:[],
          collegeName:''

    }

   // {网站工程: 3}

    initData=()=>{
     
      let arr=[]
        this.$httpReq(this.$api.getStudentList(),res=>{
          Object.keys(res.data.obj).forEach((item,index)=>{
            arr.push(
              {
              college:item,
              index:index+1,
              num:res.data.obj[item]
            }
            )
          })
          this.setState({data:arr})
        })
    }
    componentDidMount(){
        this.initData()
    }

    render(){
        const {columns,data}=this.state
        return <div className={college.box}>
           
            {/*表格 */}
            <Table columns={columns} dataSource={data} pagination={{ pageSize: 8 }}/>
        </div>
    }
}